<template>
	<view class="u-flex-col">
		<worker-header>
			<view class="content-wrap">

				<view class="border-wrap user-wrap  u-p-b-24 u-p-t-0 u-p-b-0">
					<view class="user-info-wrap u-flex u-row-right u-col-bottom">
						<view class="u-flex">
							<u-avatar class="avatar" :size="140" :src="$wanlshop.oss(userObj.avatar)"></u-avatar>
						</view>
						<view class="other-wrap u-flex u-row-between u-flex-1 u-m-l-32">
							<view class="info">
								<view class="name-wrap u-flex">
									<view class="name">{{userObj.real_name}}</view>
									<view class="tag u-flex-1 u-line-1 u-m-l-14"
										v-if="userObj.work_type_ids.length > 0">
										{{userObj.work_type_ids[0]}}
									</view>
								</view>

								<view class="location u-flex" style="color:#666666;">
									<view class="icon">
										<u-icon name="map" color="#666666"></u-icon>
									</view>
									<view class="value u-m-l-14">{{userObj.worker_area.city}}</view>
								</view>
							</view>

							<view class="action like" :class="userObj.is_follow == 1 ? 'is' : 'not'">
								<view class="btn" v-if="userObj.is_follow == 1">已关注</view>
								<view class="btn" v-else>+关注</view>
							</view>
						</view>
					</view>

					<view class="total-wrap">
						<view class="item">
							<div class="value">{{userObj.favorable_rate ? userObj.favorable_rate : 0}}%</div>
							<div class="title">好评率</div>
						</view>
						<view class="item">
							<div class="value">{{userObj.work_score ? userObj.work_score : 0}}</div>
							<div class="title">信用分</div>
						</view>
						<view class="item">
							<div class="value">{{userObj.service_users_count ? userObj.service_users_count : 0}}</div>
							<div class="title">已服务客户</div>
						</view>
						<view class="item">
							<div class="value">
								{{userObj.begin_work_time.work_years ? userObj.begin_work_time.work_years : 0}}</div>
							<div class="title">经验年数</div>
						</view>
					</view>

					<view class="skill-wrap">
						<view class="item">
							<view class="title">个人亮点</view>
							<view class="value">
								<text class="tag-item" v-for="(item, index) in userObj.tags"
									:key="index">{{item}}</text>
							</view>
						</view>
						<view class="item">
							<view class="title">服务内容</view>
							<view class="value">
								<text class="tag-item" v-for="(item, index) in userObj.work_type_ids"
									:key="index">{{item}}</text>
							</view>
						</view>
						<view class="item u-flex-col" v-if="false">
							<view class="title">资质证书</view>
							<view class="value u-m-t-40" style="">

								<scroll-view class="scroll-view_H" scroll-x="true">
									<view class="scroll-view-item_H uni-bg-red"
										v-for="(item, index) in userObj.prove_imgs" :key="index">
										<image :src="$wanlshop.oss(item)" mode="" class="prove-item"></image>
									</view>
									<view class="scroll-view-item_H uni-bg-red"
										v-for="(item, index) in userObj.prove_imgs" :key="index">
										<image :src="$wanlshop.oss(item)" mode="" class="prove-item"></image>
									</view>
								</scroll-view>
							</view>
						</view>
					</view>
				</view>

				<view class="other-wrap border-wrap u-m-t-16 u-p-b-24">

					<view class="list-case list">
						<view class="title-wrap u-flex u-row-between" @click="go_case_list(userObj.user_id)">
							<view class="title">他的案例</view>
							<view class="arrow u-flex" style="color:#999999;">
								<view>查看更多</view>
								<u-icon name="arrow-right" color="#999999"></u-icon>
							</view>
						</view>
						<view class="value-wrap">
							<scroll-view class="scroll-view_H" scroll-x="true">
								<view class="scroll-view-item_H uni-bg-red" v-for="(item, index) in userObj.case_imgs"
									:key="index" @click="go_case(item.id)">
									<image :src="$wanlshop.oss(item.img)" mode="" class="prove-item"></image>
								</view>
							</scroll-view>
						</view>
					</view>
				</view>

				<view class="border-wrap">

					<view class="list-comment list">
						<view class="title-wrap">
							<view class="title">客户评价</view>
						</view>
						<view class="value-wrap">
							<view class="" v-for="(item, index) in userObj.user_comment_list" :key="index"
								@click="go_case(item.id)">
								<case-detail :item="item"></case-detail>
							</view>
						</view>
					</view>

				</view>
			</view>
		</worker-header>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				workerTypeName: "工长",
				userinfo: {},
				userObj: {},
			}
		},
		onLoad(options) {
			let data = JSON.parse(options.item)
			if (data.level == 1) {
				this.worker_type_name = "用户";
			} else if (data.level == 2) {
				this.worker_type_name = "个人工匠";
			} else if (data.level == 3) {
				this.worker_type_name = "公司工匠";
			} else if (data.level == 5) {
				this.worker_type_name = "区域服务商 ";
			}
			this.userinfo = data;
			this.worKinfo(data.user_id)
		},
		methods: {
			worKinfo(id) {
				console.log(id)
				this.$api.get({
					url: '/worker/worker/info',
					data: {
						user_id: id
					},
					success: res => {
						console.log(res)
						this.userObj = res;
					}
				})
			},
			go_case(case_id) {
				console.log(case_id)
			},
			go_case_list(user_id) {
				uni.navigateTo({
					url: 'case-list?item=' + JSON.stringify(this.userinfo),
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content-wrap {
		margin-top: 70rpx;
		border-radius: 14rpx 14rpx 0 0;
		position: relative;
		top: -34rpx;
		margin-bottom: -34rpx;
		background: #F5F5F5;

	}

	.user-wrap {
		padding: 0 40rpx 0 40rpx;
	}

	.border-wrap {
		border-radius: 14rpx 14rpx 0 0;
		padding: 24rpx 40rpx;
		background: #ffffff;

		&+& {
			margin-top: 16rpx;
		}
	}

	.user-info-wrap {
		position: relative;
		top: -34rpx;
		margin-bottom: -34rpx;
	}

	.total-wrap {
		margin-top: 24rpx;
		display: flex;
		justify-content: space-around;

		.item {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			.value {

				height: 58rpx;
				font-family: Source Han Sans, Source Han Sans;
				font-weight: 400;
				font-size: 40rpx;
				color: #FF4731;
				line-height: 58rpx;
				text-align: right;
				font-style: normal;
				text-transform: none;
			}

			.title {

				height: 40px;
				font-family: Source Han Sans, Source Han Sans;
				font-weight: 400;
				font-size: 28rpx;
				color: #4D4D4D;
				line-height: 40rpx;
				text-align: right;
				font-style: normal;
				text-transform: none;
			}
		}
	}

	.skill-wrap {
		.item {
			display: flex;
			font-size: 24rpx;

			.tag-item {
				font-family: Source Han Sans, Source Han Sans;
				font-weight: 400;
				color: #FF8400;
				text-align: right;
				font-style: normal;
				text-transform: none;
				margin: 0 32rpx;
			}

			.title {
				width: 96rpx;
				font-family: Source Han Sans, Source Han Sans;
				font-weight: 400;
				font-size: 24rpx;
				color: #666666;
				text-align: right;
				font-style: normal;
				text-transform: none;
			}

			.value {
				flex: 1;
				display: flex;
				flex-wrap: wrap;
			}
		}

		.item+.item {
			margin-top: 40rpx;
		}
	}

	.tag {
		border-radius: 52rpx 52rpx 52rpx 52rpx;
		border: 2rpx solid #FFD4CB;
		font-family: Source Han Sans, Source Han Sans;
		font-weight: 400;
		font-size: 24rpx;
		color: #D82400;
		line-height: 34rpx;
		text-align: right;
		font-style: normal;
		text-transform: none;
		padding: 4rpx 20rpx;
	}

	.scroll-view_H {
		white-space: nowrap;
		width: 100%;
	}

	.scroll-view-item_H,
	.prove-item {
		display: inline-block;
		text-align: center;
		width: 228rpx;
		height: 144rpx;
		border-radius: 0px 0px 0px 0px;

		&+& {
			margin-left: 16rpx;
		}
	}

	.title-wrap {
		.title {
			height: 44rpx;
			font-family: Source Han Sans, Source Han Sans;
			font-weight: 500;
			font-size: 30rpx;
			color: #333333;
			line-height: 44rpx;
			text-align: left;
			font-style: normal;
			text-transform: none;
		}

		.arrow {
			height: 40rpx;
			font-family: Source Han Sans, Source Han Sans;
			font-weight: 400;
			font-size: 28rpx;
			color: #999999;
			line-height: 40rpx;
			text-align: left;
			font-style: normal;
			text-transform: none;
		}
	}

	.list {
		.value-wrap {
			margin-top: 40rpx;
			;
		}
	}
</style>